import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-10-13
 * Time: 15:20
 */
public class TestDemo {
    public static void myBubbleSort(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length-1-i; j++) {
                if(arr[j]>arr[j+1]) {
                    int temp = arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=temp;
                }
            }
        }
    }
    public static void main(String[] args) {
        int[] arr={9,5,4,6,7,8,3,2,1};
        System.out.println(Arrays.toString(arr));

        myBubbleSort(arr);
        System.out.println(Arrays.toString(arr));
    }
}
